package com.langhang.controller;

import com.langhang.SpecSearch.SpecS;
import com.langhang.entity.TbSpecification;
import com.langhang.entity.TbSpecificationOption;
import com.langhang.service.TbSpecificationOptionService;
import com.langhang.service.TbSpecificationService;
import com.langhang.util.PageResult;
import com.langhang.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/tbspec")
@CrossOrigin
public class TbSpecificationController {
    @Autowired
    private TbSpecificationService tbSpecificationService;

    @GetMapping("/list")
    public List<TbSpecification> findCLASS(){return tbSpecificationService.findCLASS();}

    @PostMapping("/search")
    public PageResult<TbSpecification> search(@RequestParam("page") Integer page,
                                              @RequestParam("pageSize") Integer pageSize,
                                              @RequestBody(required = false) SpecS specs){
        return tbSpecificationService.search(page,pageSize,specs);
    }

    // 4. 保存学生
    @PostMapping("/save")
    public R save(@RequestBody TbSpecification tbspec){
        return tbSpecificationService.save(tbspec) ? R.ok().message("添加成功！") : R.error().message("添加失败！");
    }


}
